package com.hntest.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hntest.dao.BidRequestDao;
import com.hntest.entity.BidRequest;
import com.hntest.entity.LoginInfo;
import com.hntest.entity.Pager;
import com.hntest.entity.RealAuth;
import com.hntest.service.BidRequestService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("BidRequestService")
public class BidRequestServiceImpl implements BidRequestService {

    @Autowired
    private BidRequestDao bidRequestDao;

    @Override
    public int insertBidRequest(BidRequest bidRequest) {
        return bidRequestDao.insertBidRequest(bidRequest);
    }

    @Override
    public BidRequest selectByLoginId(int id) {
        return bidRequestDao.selectByLoginId(id);
    }

    @Override
    public List<BidRequest> getListByPage(Pager pager,BidRequest bidRequest) {
        pager.setTotalCounts(bidRequestDao.getCounts(bidRequest));
        Map<String, Object> map=new HashMap<>();
        map.put("bidRequest",bidRequest);
        map.put("pageStart", (pager.getCurrPage()-1)*pager.getPageSize()+1);
        map.put("pageEnd",pager.getCurrPage()*pager.getPageSize());
        List<BidRequest> listByPage = bidRequestDao.getListByPage(map);
        return listByPage;
    }

    @Override
    public int updateBidRequest(BidRequest bidRequest) {
        return bidRequestDao.updateBidRequest(bidRequest);
    }

    @Override
    public BidRequest selectByBidRequestId(int bidRequestid) {
        return bidRequestDao.selectByBidRequestId(bidRequestid);
    }


}
